package dynamic_hybrid;


public class HybridMatrix extends Matrix
{
	
	
	private int ROW,COLUMN ;
	
	private int[][] RULEMATRIX1, RULEMATRIX2 , HYBRIDMATRIX ;
	
	
	public HybridMatrix(int[][] ruleMatrix1,int[][] ruleMatrix2)
	{
		
		this.ROW          = ruleMatrix1.length         ;
		this.COLUMN       = ruleMatrix2[0].length      ;		
		
		
		RULEMATRIX1 = ruleMatrix1;
		RULEMATRIX2 = ruleMatrix2;	
		
		HYBRIDMATRIX = hybridMatrix() ; 
		
		
	}
	
	public int[][] getHybridMatrix()
	{
		return this.HYBRIDMATRIX ;
	}
	
	
	private int[][] hybridMatrix()
	{
	     
	     int[][] result    = new int[ROW][COLUMN] ;
	   
	     for(int i = 0 ;i<ROW;i++ )
	     {
	         if(i%2 == 0)
	         {
	             System.arraycopy(RULEMATRIX1[i], 0, result[i], 0, COLUMN);            
	             
	         }

	         if(i%2 == 1)
	         {
	             System.arraycopy(RULEMATRIX2[i], 0, result[i], 0, COLUMN);
	         }
	     }
	     return result ;
	}
	
	public String toString()
	{
		    
		printMatrix(this.HYBRIDMATRIX, "HYBRID MATRIX FOR RULE :") ;
		
		return " " ;
	}

}
